

const path = require('path')

const UglifyPlugin = require('uglifyjs-webpack-plugin')


const marked = require("marked");
const renderer = new marked.Renderer();

const myPlugin = require("./plugins/1.js")
const webpack = require("webpack")



module.exports={

    entry: './src/index.js',

    output:{
        path: path.resolve(__dirname, 'dist'),
        filename: 'bundle.js',
    },

    module:{
        
        // 配置哪些模块文件的内容不需要进行解析
        noParse: /jquery|lodash/, // 正则表达式

        rules: [{
                test: /\.jsx?/,
                include: [
                    path.resolve(__dirname, 'src')
                ],
                use: [
                    {
                        loader:'babel-loader',
                        options:{
                            presets:[['es2015',{modules:false}]],
                            plugins:['syntax-dynamic-import']
                          }
                    },

                    "my-loader",

                ],
            }, {
                test: /\.md$/,
                use: [
                    {
                        loader: "html-loader"
                    },
                    {
                        loader: "markdown-loader",
                        options: {
                            pedantic: true,
                            renderer
                        }
                    }
                ]
            },
        ],
      
    },

    // resolveLoader:{
    //     // 去哪些目录下寻找 Loader，有先后顺序之分
    //     modules: ['node_modules','./loaders/'],
    // },

    resolve: {

        alias: {
            utils: path.resolve(__dirname, 'src/utils') // 这里使用 path.resolve 和 __dirname 来获取绝对路径
        },

        extensions: ['.wasm', '.mjs', '.js', '.json', '.jsx'],

    },

    plugins:[

        // new UglifyPlugin(),

        new myPlugin(),

        new webpack.optimize.SplitChunksPlugin({
            chunks: "all",
            minSize: 100,
            minChunks: 1,
            maxAsyncRequests: 5,
            maxInitialRequests: 3,
            name: true
        })

    ]

}

